package StudyCode.summary.myfile;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CreateBufferedImageByFileArray {
	public static void main(String[] args) {
		Path path = Paths.get("E:/Copy", "Test.jpg");

		try {
			byte[] bytes = Files.readAllBytes(path);
			BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(bytes));
			ImageIO.write(bufferedImage, "png", (path.resolveSibling("Convert.png")).toFile());
		} catch (IOException e) {
			System.out.println(e);
		}

	}
}
